feat: add CalendarIntervalType support - #4898
Conversation
|
Nice, clean approach to interval support. I traced the micros-to-nanos conversion through all four paths (both writers, both readers) and they are consistent, and the child-vector A few questions, none blocking:
Also heads up: the red This review was prepared with the assistance of an LLM (Claude). |
…o feat/calendar-interval-type
| _: Float4Vector | _: Float8Vector | _: DecimalVector | _: VarCharVector | | ||
| _: VarBinaryVector | _: DateDayVector | _: TimeStampMicroVector | | ||
| _: TimeStampMicroTZVector => | ||
| _: TimeStampMicroTZVector | _: IntervalMonthDayNanoVector => |
There was a problem hiding this comment.
self reminder: move this to CometLiteral.getSupportLevel after #4715 is merged.
Seems like |
andygrove
left a comment
There was a problem hiding this comment.
LGTM. Thanks @peterxcli. Could you fix conflicts?
|
@andygrove Thanks for the review! |
CalendarIntervalType support landed in apache#4898, so MakeInterval can now go through the JVM codegen dispatcher alongside TimestampAdd and TimestampDiff instead of falling the projection back to Spark. Also broadens the datetime test coverage: - timestampadd gains MILLISECOND and DAYOFYEAR, a TIMESTAMP_NTZ column (a separately compiled kernel, since TimestampAdd.dataType follows the input), DST spring-forward, fall-back and nonexistent-local-hour cases, and a DATETIME_OVERFLOW expect_error case. - timestampdiff gains MICROSECOND, MILLISECOND and QUARTER, NTZ inputs, and the matching DST cases. - The grammar routes DATEADD/DATE_ADD and DATEDIFF/DATE_DIFF/TIMEDIFF to TimestampAdd/TimestampDiff when the first argument is a datetimeUnit keyword. Those alias spellings are now covered, split by the version that introduced them: dateadd/datediff inline, date_add/date_diff in date_add_unit_alias.sql (Spark 3.5+), timediff in timediff.sql (4.0+). - make_interval and make_interval_ansi fixtures, the latter covering the ANSI overflow path where MakeInterval.failOnError is true. Corrects the date_add, date_diff, dateadd and datediff rows in the expression guide, which claimed Native without noting that this is true only of the two-argument form, and adds rows for the unit spellings.
Which issue does this PR close?
Part of #4540.
Rationale for this change
Comet does not currently support Spark's
CalendarIntervalType, causing queries carrying calendar interval columns through Comet operators to fall back to Spark.This change adds the foundational Arrow and codegen support needed to preserve calendar intervals—months, days, and microseconds—across the Spark, Arrow, and native execution boundaries.
What changes are included in this PR?
CalendarIntervalTypeto ArrowInterval(MonthDayNano).CALENDAR_INTERVALto the serialized data type protocol and native Arrow type conversion.CalendarIntervalTypesupport to Comet batch-kernel code generation for scalar and nested values.How are these changes tested?
Added coverage for:
CalendarIntervalTypethrough the Arrow writer andCometPlainVector.